home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 23
/
Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso
/
Aminet
/
text
/
edit
/
Smartindent.lha
/
Smartindent
/
Source
/
LibFuncs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-12-14
|
4KB
|
139 lines
/*(( "Kopf" */
/* -----------------------------------------------------------------------------
$Id: LibFuncs.c,v 1.4 1997/06/26 14:27:02 mshopf Exp mshopf $
GoldED API client, ©1997 Matthias Hopf.
Compiled with SasC.
Library entry functions.
------------------------------------------------------------------------------
*/
/*)) */
/*(( "Includes" */
#include "compiler.h"
#include "LibFuncs.h"
#include "dispatcher.h"
#include "util.h"
#include <proto/exec.h>
#include <exec/types.h>
#include <exec/memory.h>
#include <proto/intuition.h>
/*)) */
/*(( "General comments" */
/* Please note, that &ExampleBase always resides in register __a6 as well,
but if we don't need it, we need not reference it here.
Also note, that registers a0, a1, d0, d1 always are scratch registers,
so you usually should only *pass* parameters there, but make a copy
directly after entering the function. To avoid problems of kind
"implementation defined behaviour", you should make a copy of A6 too,
when it is actually used.
*/
/*)) */
/*(( "L_MountClient ()" */
/***** Called once for every window it is used. *****/
struct APIClient * SAVEDS ASM L_MountClient (REG(a0) struct APIMessage *msg_ GNUCREG("a0"), REG(a1) char *args_ GNUCREG("a1"))
{
char *args = args_;
struct APIMessage *msg = msg_;
sc_t *c;
if (! (c = AllocMem (sizeof (sc_t), MEMF_PUBLIC | MEMF_CLEAR)))
return NULL;
if (! ScanArgs (c, args, msg))
{
FreeMem (c, sizeof (sc_t));
return NULL;
}
#if API_INTERFACE_VERSION != 3
# error "This client needs headers for API interface version 3
#endif
c->API.api_APIVersion = API_INTERFACE_VERSION;
c->API.api_Version = 1;
c->API.api_Name = "Smartindent API";
c->API.api_Info = "Indenting C and other code";
c->API.api_Commands = apiCommands;
c->API.api_Serial = 0;
c->API.api_Classes = API_CLASS_COMMAND | API_CLASS_KEY;
c->API.api_Area = NULL;
return ((struct APIClient *) c);
}
/*)) */
/*(( "L_CloseClient ()" */
void SAVEDS ASM L_CloseClient (REG(a0) struct APIClient *client_ GNUCREG("a0"), REG(a1) struct APIMessage *msg_ GNUCREG("a1"))
{
/* we don't save the arguments, because we only call a function and don't need them afterwards */
FreeMem (client_, sizeof (sc_t));
}
/*)) */
/*(( "L_BriefClient ()" */
/***** Notify Routine. This is called for all event classes specified above. *****/
void SAVEDS ASM L_BriefClient (REG(a0) struct APIClient *client_ GNUCREG("a0"), REG(a1) struct APIMessage *msg_ GNUCREG("a1"))
{
sc_t *client = (sc_t *) client_;
struct APIMessage *msg = msg_;
while (msg)
{
if (msg->api_State == API_STATE_NOTIFY)
{
switch (msg->api_Class) {
case API_CLASS_KEY:
if (msg->api_Action == API_ACTION_VANILLAKEY)
DispatchKey (client, msg);
break;
// case API_CLASS_SYSTEM: /* currently unused */
case API_CLASS_COMMAND:
if (msg->api_Action == API_ACTION_COMMAND)
DispatchCmd (client, msg);
else
msg->api_Error = API_ERROR_UNKNOWN;
break;
default:
msg->api_Error = API_ERROR_UNKNOWN;
}
}
msg = msg->api_Next;
}
}
/*)) */
/*(( "L_Free ()" */
/***** Order structure is consumed by Host and we may now free it. *****/
void SAVEDS ASM L_Free (REG(a0) struct APIClient *client GNUCREG("a0"), REG(a1) struct APIOrder *order GNUCREG("a1"))
{
/* we don't save the arguments, because we only call a function and don't need them afterwards */
FreeRequest ((sc_t *) client, (struct SmartOrder *) order);
}
/*)) */